From: Colin Walters Date: Fri, 25 Jul 2014 11:55:55 +0000 (-0400) Subject: core: Support a per-remote "proxy" configuration option X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~1134 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b97a5f59df26267b893a05b3cecbe04fe6e8db7e;p=ostree.git core: Support a per-remote "proxy" configuration option We don't want to have to force people to set it in the environment. https://bugzilla.gnome.org/show_bug.cgi?id=733734 --- diff --git a/doc/ostree.repo-config.xml b/doc/ostree.repo-config.xml index bbacdd08..26fef077 100644 --- a/doc/ostree.repo-config.xml +++ b/doc/ostree.repo-config.xml @@ -126,6 +126,12 @@ Boston, MA 02111-1307, USA. https. + + proxy + A string value, if given should be a URL for a + HTTP proxy to use for access to this repository. + + gpg-verify A boolean value, defaults to true. diff --git a/src/libostree/ostree-fetcher.c b/src/libostree/ostree-fetcher.c index 0ea4d29d..298ba63f 100644 --- a/src/libostree/ostree-fetcher.c +++ b/src/libostree/ostree-fetcher.c @@ -172,16 +172,7 @@ _ostree_fetcher_init (OstreeFetcher *self) http_proxy = g_getenv ("http_proxy"); if (http_proxy) { - SoupURI *proxy_uri = soup_uri_new (http_proxy); - if (!proxy_uri) - { - g_warning ("Invalid proxy URI '%s'", http_proxy); - } - else - { - g_object_set (self->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL); - soup_uri_free (proxy_uri); - } + _ostree_fetcher_set_proxy (self, http_proxy); } if (g_getenv ("OSTREE_DEBUG_HTTP")) @@ -224,6 +215,22 @@ _ostree_fetcher_new (GFile *tmpdir, return self; } +void +_ostree_fetcher_set_proxy (OstreeFetcher *self, + const char *http_proxy) +{ + SoupURI *proxy_uri = soup_uri_new (http_proxy); + if (!proxy_uri) + { + g_warning ("Invalid proxy URI '%s'", http_proxy); + } + else + { + g_object_set (self->session, SOUP_SESSION_PROXY_URI, proxy_uri, NULL); + soup_uri_free (proxy_uri); + } +} + void _ostree_fetcher_set_client_cert (OstreeFetcher *fetcher, GTlsCertificate *cert) diff --git a/src/libostree/ostree-fetcher.h b/src/libostree/ostree-fetcher.h index 850d3178..0ab1def4 100644 --- a/src/libostree/ostree-fetcher.h +++ b/src/libostree/ostree-fetcher.h @@ -54,6 +54,9 @@ GType _ostree_fetcher_get_type (void) G_GNUC_CONST; OstreeFetcher *_ostree_fetcher_new (GFile *tmpdir, OstreeFetcherConfigFlags flags); +void _ostree_fetcher_set_proxy (OstreeFetcher *fetcher, + const char *proxy); + void _ostree_fetcher_set_client_cert (OstreeFetcher *fetcher, GTlsCertificate *cert); diff --git a/src/libostree/ostree-repo-pull.c b/src/libostree/ostree-repo-pull.c index 51eb4d0c..76798d6e 100644 --- a/src/libostree/ostree-repo-pull.c +++ b/src/libostree/ostree-repo-pull.c @@ -1151,6 +1151,17 @@ ostree_repo_pull (OstreeRepo *self, } } + { + gs_free char *http_proxy = NULL; + + if (!ot_keyfile_get_value_with_default (config, remote_key, "proxy", + NULL, &http_proxy, error)) + goto out; + + if (http_proxy) + _ostree_fetcher_set_proxy (pull_data->fetcher, http_proxy); + } + if (!pull_data->base_uri) { g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,